<script type="text/javascript">
$(document).ready(function(){
	//xóa
	$("#btnDelete").click(function(){
		var valid= false;
		var arrChkId = $(".chkId");
		var strIDs = "";
		for(var i =0; i < arrChkId.length; i++){
			if(arrChkId.eq(i).attr("checked")){
				valid = true;
				if(strIDs!=""){
					strIDs +=","+ arrChkId.eq(i).attr("value");
				}else{
					strIDs +=arrChkId.eq(i).attr("value");
				}
				//break;
			}
		}
		if(valid){
			if(confirm("Bạn thực sự muốn xóa những chuyên mục này?")){
				$("#hddIDs").attr("value", strIDs);
				$("#frmActions").attr("action", "<?php echo $this->url(array(),'admin_user_delete');?>");
			}else{
				return false;
			}
		}else{
			alert("Xin hãy chọn chuyên mục muốn xóa!");
			return false;
		}
	});
});
</script>
<div id="r-heading">
	<img src="<?php echo PUBLIC_URL.'/admin/images/user.png';?>" alt=""/>
	<span>Danh sách Supporter</span>
</div>
<?php
//nếu có message thì hiển thị
if(!empty($this->message)){
	echo '<div id="message">'.$this->message.'</div>';
} 
?>
<div style="width: 100%;">
	<form id="frmActions" action="" method="post">
		<div id="actions">
			<!--<input type="text" id="txtKeyword" name="keyword" class="text" value="" size="25"/>  -->
			<!--<input type="submit" id="btnSearch" class="button" value="Tìm kiếm"/>  -->
			<input type="button" id="btnCreate" class="button" value="Thêm mới" onclick="location = '<?php echo $this->url(array(), 'admin_supporter_create');?>';"/>
			<input type="submit" id="btnDelete" class="button" value="Xóa các mục đã chọn"/>
			<input type="hidden" id="hddIDs" value="" name="ids"/>
			
		</div>
		<table class="list" cellspacing="0">
			<thead>
				<tr>
					<td width="3%">
						<input type="checkbox" class="chkAll"/>
					</td>
					<td width="20%">
						Tên supporter
					</td>
					<td width="25%">
						Email
					</td>
					<td width="10%">
						Phone
					</td>
					<td width="10%">
						Yahoo
					</td>
					<td width="20%">
						Loại tài khoản
					</td>
					<td width="10%">
						Thao tác
					</td>
				</tr>
			</thead>
			<tbody>
				<?php
					$count = count($this->arrSupporters);
					if($count == 0){
				?>
					<tr>
						<td colspan="7" style="color: #fc0202;">
							Chưa có supporter nào trong cơ sở dữ liệu!
						</td>
					</tr>
				<?php
					}else{
						for($i = 0; $i< $count; $i++){
				?>
					<tr <?php if($i == $count - 1) echo 'class="last"';?>>
						<td>
							<input type="checkbox" class="chkId" value="<?php echo $this->arrSupporters[$i]->id; ?>"/>
						</td>
						<td>
							<a href="<?php echo  $this->url(array('id' => $this->arrSupporters[$i]->id), 'admin_supporter_edit');?>" title="Sửa thông tin supporter">
								<?php
									
									echo $this->arrSupporters[$i]->name;
								?>
							</a>
						</td>
						<td>
							<?php echo $this->arrSupporters[$i]->email;?>
						</td>
						<td>
							<?php echo $this->arrSupporters[$i]->phone;?>
						</td>
						<td>
							<?php echo $this->arrSupporters[$i]->yahoo_account;?>
						</td>
						<td>
							<?php
								switch($this->arrSupporters[$i]->type){
									case 0: echo "Hỗ trợ bán hàng"; break;
									case 1: echo "Hỗ trợ kỹ thuật"; break;
									default: echo "Không rõ"; break;
								}
							?>
						</td>
						<td>
							<a href="<?= $this->url(array('id' => $this->arrSupporters[$i]->id), 'admin_supporter_edit');?>" title="Sửa thông tin Supporter">Sửa</a>
							|
							<a onclick="if(!confirm('bạn muốn xóa?')) {return false;}" href="<?= $this->url(array('id' => $this->arrSupporters[$i]->id), 'admin_supporter_delete');?>">Xóa</a>
						</td>
					</tr>
				<?php
						}
					}
				?>
			</tbody>
			<tfoot>
				<tr>
					<td width="3%">
						<input type="checkbox" class="chkAll"/>
					</td>
					<td width="20%">
						Tên supporter
					</td>
					<td width="25%">
						Email
					</td>
					<td width="10%">
						Phone
					</td>
					<td width="10%">
						Yahoo
					</td>
					<td width="20%">
						Loại tài khoản
					</td>
					<td width="10%">
						Thao tác
					</td>
				</tr>
			</tfoot>
		</table>
	</form>
</div>